/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxinline.servico;

import br.com.foxinline.modelo.Horario;
import br.com.foxinline.modelo.ItemHorario;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;

/**
 *
 * @author laverson
 */
@Stateless
public class ItemHorarioServico extends ServicoGenerico<ItemHorario> {

    public ItemHorarioServico() {
        super(ItemHorario.class);
    }

    public List<ItemHorario> pesquisar(Horario h) {
        String sql = "SELECT item FROM ItemHorario item ";

        if (h != null && h.getId() != null) {
            sql += "WHERE item.horario.id = :id";
        }

        Query query = getEntityManager().createQuery(sql);

        if (h != null && h.getId() != null) {
            query.setParameter("id", h.getId());
        }

        return query.getResultList();
    }
}
